package com.example.demo.service.Impl;

import com.example.demo.mapper.DeptMapper;
import com.example.demo.pojo.Dept;
import com.example.demo.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service  // == @Component
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;

    @Override
    public List<Dept> findAllDepts() {
        List<Dept>  list  = deptMapper.selectAllDepts();
        return list;
    }

    @Override
    public int deleteDeptById(int id) {
        int row=deptMapper.deleteDeptById(id);
        return row;
    }

    @Override
    public int insertDept(Dept dept) {
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        int row=deptMapper.insertDept(dept);
        return row;
    }

    @Override
    public Dept findDeptById(int id) {
        Dept dept=deptMapper.findDeptById(id);
        return dept;
    }

    @Override
    public int updateDept(Dept dept) {
        int row=deptMapper.updateDept(dept);
        return row;
    }


}
